'use strict';
	angular.module('purchase.purchaseOrderDetailQueryList', ['app.services'])

	.controller('purchaseOrderDetailQueryListCtrl',['$rootScope', '$scope', 'BizData', f])
    function f($rootScope, $scope, BizData) {

		var Model = this;
		
		var options = {};
		options.container = Model;
		options.concept = 'PurchaseOrderDetail';
		options.name = 'dataMaster';
		options.url = $rootScope.path;
		options.httpUrl = $rootScope.getServiceName();
		options.reader = '/purchase/orderDetailQuery/list/query';
		options.writer = '';
		options.deleter = '';
		options.idColumnDefine = "fID";
		options.idColumnName = "fID";
		options.isTree = false;
		options.parentRelation = 'fParent';
		options.nodeKindRelation = 'nodeKind';
		options.nodeLevelRelation = 'nodeLevel';
		options.pathRelation = '';
		options.master = {"data":"","relation":""};
		options.directDeleteMode = false;
		options.orderBy = 'stockNo,serialNo ASC';
		options.limit = 15;
		//聚合列
		options.aggregateColumns = {"itemAmount":{name:"sumItemAmount",type:"Decimal",label:""},"orderAmountTotal":{name:"sumTotalAmount",type:"Decimal",label:""},"CONVERT(FileItem.costingStandardPer*itemAmount,decimal(38,2))":{name:"sumCostingStandardPer",type:"Decimal",label:""},"orderAmountTotal-CONVERT(FileItem.costingStandardPer*itemAmount,decimal(38,2))":{name:"sumProfitAmount",type:"Decimal",label:""}};

		Model.dataMaster = new BizData(options);

		//监视对象中的所有变动
//		Model.dataMaster.deregRows = $scope.$watch('dataMaster.rows',Model.dataMaster.watchRows,true);//true代表深度监视，包括对象的属性，而不是简单的一个值
		//////////////////////////////////////////////

		//设置过滤条件
		Model.dataMaster.filter = " PurchaseOrderDetail.billType='CGDD' "
			+ " AND PurchaseOrderDetail.audit='confirm' "
								
		;

		//刷新数据
		Model.dataMaster.refreshData();
//		console.log('Model.dataMaster-->',Model.dataMaster);
		////////////////////启动执行结束///////////////////////////////////////////////////
	    
		Model.refresh = function(){
			Model.dataMaster.refreshData();
		}
	    
		Model.query = function(){
			Model.dataMaster.queryData();
		}

		Model.filters = [];
		
	    return Model;
		
	}	
	
